import 'package:flutter/material.dart';

class CustomLinearProgress extends CustomPainter {
  final double width;
  final double widthTop;

  const CustomLinearProgress(
      {required this.width,required this.widthTop});

  @override
  void paint(Canvas canvas, Size size) {
    final paint = Paint()
      ..color = Colors.green
      ..strokeWidth = 2
      ..style = PaintingStyle.fill;

    final rect = Rect.fromLTWH(0, 0, width, 4);
    const radius = Radius.circular(20.0);
    final roundedRect = RRect.fromRectAndCorners(rect,
        topLeft: radius,
        topRight: radius,
        bottomLeft: radius,
        bottomRight: radius);

    canvas.drawRRect(roundedRect, paint);

    final rectTop = Rect.fromLTWH(0, 0, widthTop, 4);

    paint.color = Colors.red;
    final roundedTop = RRect.fromRectAndCorners(rectTop,
        topLeft: radius,
        topRight: radius,
        bottomLeft: radius,
        bottomRight: radius);
    canvas.drawRRect(roundedTop, paint);

    paint.color = Colors.white;
    canvas.drawCircle(Offset(widthTop, 4/2), 12, paint);

  }

  @override
  bool shouldRepaint(CustomPainter oldDelegate) => true;
}
